package com.winz.cultureapp.http;

import io.reactivex.Observer;
import io.reactivex.annotations.NonNull;
import io.reactivex.disposables.Disposable;

/**
 * Created by terry on 2018/1/12.
 */

public class RetrofitUtil<T> implements Observer<T> {

    public OnResponeListener<T> listener;

    @Override
    public void onSubscribe(@NonNull Disposable d) {
    }

    @Override
    public void onNext(@NonNull T o) {
        if (listener != null){
            listener.onSuccess(o);
        }
    }

    @Override
    public void onError(@NonNull Throwable e) {
        if (listener != null){
            listener.onFailed(e.toString());
        }
    }

    @Override
    public void onComplete() {

    }

    public RetrofitUtil setOnResponeListener(OnResponeListener<T> listener){
        this.listener = listener;
        return this;
    }


}
